{extend name="Public:base"/}

{block name="main"}
<div class="box-info">
    <form id="myform" action="{:U('Model/insert')}" method="post">
        <div class="form-group row">
            <label class="form-control-label col-md-2"><font color="red">*</font>模型名称</label>
            <div class="col-md-5">
                <input type="text" name="name" value="{$vo.name}" size="20" class="form-control" placeholder="由中文或英文组成"/>
            </div>
        </div>
        <div class="form-group row">
            <label class="form-control-label col-md-2"><font color="red">*</font>模型表名</label>
            <div class="col-md-5">
                <input type="text" name="tablename" value="{$vo.tablename}" size="20" class="form-control" placeholder="由英文字母组成，首字母大写"/>
            </div>
        </div>
        <div class="form-group row">
            <label class="form-control-label col-md-2">列表页调用字段</label>
            <div class="col-md-5">
                <input type="text" id="listfields" name="listfields" class="form-control" size="55" value=""/>
                {:L(examples)}:id,title,url,catid
            </div>
        </div>
        <div class="form-group row">
            <label class="form-control-label col-md-2">前台搜索模型</label>
            <div class="col-md-5">
                {:Form::radio(array('field'=>'issearch','options'=>array('1'=>L('yes'),'0'=>L('no'))),$vo['issearch'])}
            </div>
        </div>

        <div class="form-group row">
            <label class="form-control-label col-md-2">模型简介</label>
            <div class="col-md-5"><textarea id="description" name="description" rows=4""
                                            cols="55">{$vo.description}</textarea>
            </div>
        </div>

        <div class="form-group row">
            <label class="form-control-label col-md-2">新建表字段</label>
            <div class="col-md-5">
                <input type="radio" name="emptytable" value="1"/> 空表字段
                <input type="radio" name="emptytable" value="0" checked/>普通文章表字段
            </div>
        </div>
        <input type="hidden" id="type" name="type" value="{$_GET[type]}"/>
        <div class="form-actions">
            <button type="submit" class="btn btn-primary">提交</button>
            <button type="button" class="btn btn-danger" onclick="javascript:history.back(-1);return false;">返回</button>
        </div>
    </form>
</div>

{/block}


{block name="script"}
<script type="text/javascript">
    $(document).ready(function () {
        $('#myform').ajaxForm({
            success: complete,  // post-submit callback
            dataType: 'json'
        });
    });

    function complete(data) {
        if (data.status == 1) {
            layer.msg(data.info, {
                icon: 1,
                time: 2000 //2秒关闭（如果不配置，默认是3秒）
            }, function () {
                window.location.href = "{$Think.cookie.__forward__}";
                return true;
            });
        } else {
            layer.msg(data.info, {
                icon: 2,
                time: 2000 //2秒关闭（如果不配置，默认是3秒）
            });
        }
    }
</script>
{/block}